home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.2 KB

  1. Path: news.cencom.net!ns!tanp
  2. From: tanp@ns (Bill Wendling)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with program
  5. Date: 19 Jan 1996 04:34:38 GMT
  6. Organization: Cen-Com Internet
  7. Message-ID: <4dn70u$43o@news.cencom.net>
  8. References: <4dkr5u$ro7@hasle.sn.no>
  9. NNTP-Posting-Host: ns.cencom.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Rune Elvemo inexplicably wrote:
  13.  
  14. } /* Loadfile.c - loads a txt file, and shows it 
  15. } **
  16. } **
  17. } */
  18.  
  19. } #include <stdio.h>
  20.  
  21. } struct Text
  22. } {
  23. } char *str;
  24. } struct Text *next;
  25. } }
  26.   ^^ You need a semi-colon after this struct def!!!!!!!
  27.  
  28. } enum BOOL { TRUE, FALSE };
  29.  
  30. } /* prototype */
  31. } void PText(struct Text *);
  32.  
  33.  
  34. } main(int argc, char *argv[])
  35. } {
  36. } BOOL done = FALSE;
  37. } FILE *txtfile;
  38. } struct Text *first, *tst;
  39.  
  40. } if (argc >1)
  41. }      {
  42. }      if (txtfile = fopen(argv[1], "r"))
  43. }           {
  44. }           if(first = calloc(1, sizeof(struct Text)))
  45. }                {
  46. }                tst = first;
  47. }                if (fgetc(txtfile) != -1)
  48. }                     {
  49. }                     while (!done)
  50. }                          {
  51. }                          if (tst->str = calloc(256, sizeof(char)))
  52. }                               {
  53. }                               do
  54. }                                    {
  55. }                                    *tst->str = fgetc(txtfile);
  56. }                                    tst->str++;
  57. }                                    *tst->str = 0;
  58. } /* check if the last char was LineFeed or EOF  */
  59.  
  60. }                                    } while ((*(tst->str - 1) != -1) &&
  61. } (*(tst->str) != 10));
  62. }                                    
  63. }                               if (*tst->str == -1)
  64. }                                    done = TRUE;
  65. }                               else
  66. }                                    {
  67. }                                    if (tst->next = calloc(1,
  68. } sizeof(struct Text)))
  69. }                                         {
  70. }                                         tst = tst->next;
  71.  
  72. }                                         }
  73. }                                    else
  74. }                                         {
  75. }                                         done = TRUE;
  76. }                                         printf("\n**!!Not enough
  77. } memory!!**\n");
  78. }                                         }
  79. }                                    }
  80. }                               }
  81. }                          }
  82. }                     tst->next = calloc(1, sizeof(struct Text));
  83. }                     
  84. }                     
  85. }                     PText(first);
  86. }                     }
  87. }                }
  88. }           else
  89. }                printf("\n**!!Not enough memory!!**\n");
  90. }           }
  91. }      }
  92. } }
  93. }      
  94. } /* Print the text that we have got */
  95. } void PText(struct Text *txt)
  96. } {
  97. } BOOL done = FALSE;
  98. } struct Text *jump;
  99.  
  100. } jump = txt;
  101.  
  102. } while(!done)
  103. }      {
  104. }      printf("%s", jump->str);
  105. }      
  106. }      while (*txt->next != 0)
  107. }           {
  108. }           jump = jump->next;
  109. }           
  110. }           printf("%s\n", jump);
  111. }           }
  112. }      }
  113. } }
  114. } Rune Elvemo
  115. } elvemo@oslonett.no
  116.  
  117.  
  118. --
  119. Bill Wendling         | "Pinky, are you thinking what I'm thinking?"
  120. tanp@ns.cencom.net  | "I think so, Brain, but burlap chafes me so."
  121. "Boom Shanka"       | Finger me for my Geek Code...NOW!
  122.